<template>
  <div>
    <el-card>
      <el-form :model="goodForm" ref="ruleForm" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="商品名称">
              <el-input v-model="goodForm.goodsName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="商品标题">
              <el-input v-model="goodForm.goodsType"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="原价格">
              <el-input v-model="goodForm.yprice"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="类型">
              <el-input v-model="goodForm.type"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="秒杀价格">
              <el-input v-model="goodForm.xprice"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="秒杀数量">
              <el-input v-model="goodForm.num"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="描述">
              <el-input v-model="goodForm.title"></el-input>
            </el-form-item>
          </el-col>
<!--          <el-col :span="12">-->
<!--            <el-form-item label="开始时间">-->
<!--              <el-date-picker v-model="goodForm.beginTime" type="date" placeholder="请选择日期"></el-date-picker>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
        </el-row>
        <el-form-item align="center">
          <el-button type="primary" @click="" plain>取消</el-button>
          <el-button type="primary" @click="savegoods()" plain>提交</el-button>
        </el-form-item>
      </el-form>

    </el-card>
  </div>
</template>

<script>
  export default {
    name: 'AddGoods',
    data(){
      return{
        goodForm:{},

      }
    },
    methods:{

      savegoods:function(){
        this.goodForm.aid = this.admin.id;
        this.$http.post("/admin/addGoods",this.goodForm).then((res)=>{
          if(res.data.success){
            this.$message.success(res.data.message);
            this.goodForm={};
            this.$router.push("/home");
          }else{
            this.$message.error(res.data.message);
          }
        })
      }
    },

    mounted () {
      this.admin = JSON.parse(sessionStorage.getItem("admin"));
    },
  }
</script>

<style scoped>

</style>
